package com.colin.aiyi.view;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;

import com.colin.aiyi.R;
import com.ldoublem.loadingviewlib.view.LVGearsTwo;

import static android.R.attr.width;

/**
 * Created by hl on 2017/6/22.
 */

public class ShowMsgUtil {

    private static Dialog dialog;
    private static MyDialog loadingDialog;

    public static void showLoadingDialog(Context context){
        if (loadingDialog!=null&&loadingDialog.isShowing())
            return;
        loadingDialog=new MyDialog(context,"玩命加载中...");
            //显示Dialog
        loadingDialog.show();
    }

    public static void  hideLoadingDialog(){
        if (loadingDialog!=null)
            loadingDialog.close();
    }

//    public static void  showLoadingDialog(Context context) {
//        LayoutInflater inflater=LayoutInflater.from(context);
//        View  view=inflater.inflate(R.layout.layout_loading_gearstwo,null);
//        com.ldoublem.loadingviewlib.view.LVGearsTwo lvGearsTwo= (LVGearsTwo) view.findViewById(R.id.lv_gears_two);
//        lvGearsTwo.startAnim();
//        lvGearsTwo.setViewColor(context.getResources().getColor(R.color.orangered));
//        showLoadingDialog(context,view);
//    }
//
//    public static void  showLoadingDialog(Context context,View view) {
//        if (dialog!=null&&dialog.isShowing())
//        {
//            return;
//        }
//        dialog = new Dialog(context);
//        Window window = dialog.getWindow();/// 设置宽度为屏宽, 靠近屏幕底部。  // window.setWindowAnimations(R.style.dialog_theme);
//        WindowManager.LayoutParams lp = window.getAttributes();
//        lp.gravity = Gravity.BOTTOM; // 紧贴底部
//        lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
//        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
//        window.setAttributes(lp);
//        RelativeLayout.LayoutParams params=
//                new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
//                        RelativeLayout.LayoutParams.WRAP_CONTENT);
//        dialog.addContentView(view, params );
//        dialog.setTitle("正在加载...");
//        dialog.show();
//        dialog.setCanceledOnTouchOutside(true);
//    }
//
}
